<template>
	<div class="video-wrapper">
		<!-- 导航栏 -->
		<div class="video-nav">
			<ul class="video-nav-ul">
				<li><a>全部</a></li>
				<li><a>连载动画</a></li>
				<li><a>完结动画</a></li>
				<li><a>资讯</a></li>
				<li><a>官方延伸</a></li>
				<li><a>新番时间表</a></li>
				<li><a>番剧索引</a></li>
			</ul>
			<a class="video-nav-img"
				><img src="./static/images/nav-img.webp" alt=""
			/></a>
		</div>
		<!-- 轮播图 -->
		<carouselComp />
		<!-- 最近更新 -->
		<div class="newUpdate-wrapper">
			<div class="newUpdate-header">
				<div class="newUpdate-title">
					<h4>最近更新</h4>
					<a>新番时间表></a>
				</div>
			</div>
			<div class="newUpdate-content">
				<ul class="content">
					<li
						v-for="item in newUpdateList"
						:key="item.uid"
						class="contentItem"
						@click="toDetail(item.vid)"
					>
						<a class="contentItem-left">
							<img :src="item.coverPic" alt="item.uid" />
						</a>
						<div class="contentItem-right">
							<p>{{ item.vTitle }}</p>
							<div class="contentItem-right-div">
								<p>更新至</p>
								<a>{{ item.upTo }}话</a>
							</div>
						</div>
					</li>
				</ul>
				<div class="content-more">
					<div class="more">
						<span>全部 ︾</span>
					</div>
				</div>
			</div>
		</div>
		<!-- 番剧索引 -->
		<div class="index-wrapper">
			<div class="index-item">
				<div class="index-item-top">
					<p>热播</p>
					<a>全部></a>
				</div>
				<div class="index-item-bottom">
					<a>追番人数</a>
					<a>最高评分</a>
					<a>播放数量</a>
				</div>
			</div>
			<div class="index-item">
				<div class="index-item-top">
					<p>时间</p>
					<a>全部></a>
				</div>
				<div class="index-item-bottom">
					<a>2022</a>
					<a>2021</a>
					<a>2020</a>
					<a>2019</a>
					<a>2018</a>
					<a>2017</a>
					<a>2016</a>
				</div>
			</div>
			<div class="index-item">
				<div class="index-item-top">
					<p>风格</p>
					<a>全部></a>
				</div>
				<div class="index-item-bottom">
					<a>原创</a>
					<a>漫画改</a>
					<a>小说改</a>
					<a>游戏改</a>
					<a>特摄</a>
					<a>布袋戏</a>
					<a>热血</a>
					<a>穿越</a>
				</div>
			</div>
			<div class="index-item">
				<div class="index-item-top">
					<p>热搜</p>
					<a></a>
				</div>
				<div class="index-item-bottom">
					<a>4月新番</a>
					<a>鬼灭之刃游郭篇</a>
					<a>盾勇2</a>
					<a>间谍</a>
					<a>过家家</a>
				</div>
			</div>
		</div>
		<!-- 精选 -->
		<div class="select">
			<div class="select-left">
				<div class="select-left-title">
					<p>编辑精选</p>
					<div>
						<i></i>
						<span>换一批</span>
					</div>
				</div>
				<ul class="select-left-content">
					<li>
						<a>
							<div>
								<img src="./static/images/jingxuan1.gif" alt="" />
								<i></i>
							</div>
							<p>测不准的阿波连同学测不准的阿波连同学</p>
						</a>
					</li>
					<li v-for="item in editList" :key="item.uid">
						<a>
							<div>
								<img :src="item.coverPic" alt="" />
								<i></i>
							</div>
							<p>{{ item.vTitle }}</p>
						</a>
					</li>
				</ul>
			</div>
			<div class="select-right">
				<div class="select-right-title">
					<p>话题精选</p>
				</div>
				<div class="select-right-content">
					<ul>
						<li>
							<a>
								<img src="./static/images/jingxuan-r1.webp" alt="" />
							</a>
						</li>
						<li>
							<a>
								<img src="./static/images/jingxuan-r2.webp" alt="" />
							</a>
						</li>
					</ul>
				</div>
			</div>
		</div>
		<!-- 连载动画 -->
		<div class="play">
			<categoryLeft :playList="playListPart" title="连载动画" />
			<categoryRight :liNum="7" />
		</div>
		<!-- 完结动画 -->
		<div class="play">
			<categoryLeft :playList="playListAll" title="完结动画" />
			<div>
				<recommendComp />
				<categoryRight :liNum="5" />
			</div>
		</div>

		<!-- 回到顶部 -->
		<div
			class="back-to-top"
			@click="toTop"
			:class="{
				noshow: this.isShow,
			}"
		>
			<span>^</span>
		</div>
	</div>
</template>

<script>
import carouselComp from "./components/carousel";
import categoryLeft from "./components/categoryLeft";
import categoryRight from "./components/categoryRight";
import recommendComp from "./components/recommend";
import axios from "axios";

export default {
	name: "VideoComp",
	components: {
		carouselComp,
		categoryLeft,
		categoryRight,
		recommendComp,
	},
	data() {
		return {
			newUpdateList: [],
			playListPart: [],
			playListAll: [],
			editList: [],
			isShow: false,
		};
	},
	async mounted() {
		const playList = await axios({
			url: "/api/fanju",
			method: "GET",
		});

		// 最近更新
		this.newUpdateList = playList.data.data.slice(0, 15);
		// 连载动画
		this.playListPart = playList.data.data.slice(5, 20);

		// 完结动画
		this.playListAll = playList.data.data.slice(15, 35);

		// 编辑精选
		this.editList = playList.data.data.slice(36, 40).reverse();

		window.addEventListener("scroll", this.getScrollTop, true);
	},
	methods: {
		getScrollTop() {
			let height = document.documentElement.scrollTop;
			if (height > 600) {
				this.isShow = false;
			} else {
				this.isShow = true;
			}
		},
		toTop() {
			document.documentElement.scrollTop = 0;
		},
		toDetail(id) {
			this.$router.push({
				name: "Detail",
				query: {
					vid: id,
				},
			});
		},
	},
};
</script>

<style lang="less" scoped>
html,
body,
ul,
li,
h4,
p {
	margin: 0;
	padding: 0;
}
ul,
li {
	list-style: none;
}
a {
	text-decoration: none;
	cursor: pointer;
}
.video-wrapper {
	width: 1160px;
	margin: 0 auto;
	overflow: hidden;
}
.video-nav {
	width: 1160px;
	height: 32px;
	margin: 9px 0 20px;
	display: flex;
	color: #ccc;
}
.video-nav-ul {
	width: 1060px;
	display: flex;
	flex: 1;
}
.video-nav-ul li {
	padding: 0 20px;
	font-size: 14px;
	text-align: center;
}
.video-nav-ul li:first-child {
	padding-left: 0;
}
.video-nav-ul li:last-child {
	padding-right: 0;
}
.video-nav-ul li a:hover {
	color: #00a1d6;
}
.video-nav-img {
	width: 100px;
	height: 32px;
}
.video-nav-img img {
	width: 100%;
	height: 100%;
}

.newUpdate-wrapper {
	width: 1160px;
	height: 400px;
	margin: 0 auto 40px;
}
.newUpdate-header {
	height: 44px;
}
.newUpdate-title {
	display: flex;
	justify-content: space-between;
	padding-bottom: 20px;
}
.newUpdate-title h4 {
	font-weight: normal;
	font-size: 24px;
}
.newUpdate-title a {
	font-size: 14px;
	text-align: center;
	display: block;
	width: 106px;
	height: 24px;
	line-height: 24px;
	cursor: pointer;
	color: pink;
	border: 1px solid pink;
	border-radius: 5px;
}

.newUpdate-content {
	width: 1160px;
	height: 355px;
}
.content {
	margin-right: -65px;
	display: flex;
	flex-wrap: wrap;
	height: 315px;
	width: 1225px;
	overflow: hidden;
}
.contentItem {
	display: flex;
	width: 180px;
	height: 72px;
	padding: 0 65px 35px 0;
}
.contentItem-left {
	display: block;
	width: 72px;
	height: 72px;
	margin-right: 12px;
}
.contentItem-left img {
	width: 100%;
	height: 100%;
}
.contentItem-right {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	width: 92px;
	height: 72px;
	font-size: 12px;
	&:hover > p {
		color: #00a1d6;
	}
}
.contentItem-right > p {
	cursor: pointer;
	width: 92px;
}
.contentItem-right-div {
	margin-top: 2px;
	display: flex;
	justify-content: space-between;
}
.contentItem-right-div a {
	display: inline-block;
	border-radius: 9px;
	color: white;
	background-color: pink;
	text-align: center;
	margin-right: 10px;
	padding: 0 4px;
	height: 18px;
	line-height: 18px;
}

.content-more {
	width: 1160px;
	height: 40px;
}
.content-more .more {
	cursor: pointer;
	margin: 0 auto;
	width: 800px;
	text-align: center;
	border-top: 1px solid #ccc;
}
.content-more .more span {
	display: inline-block;
	border: 1px solid #ccc;
	border-top: none;
	font-size: 12px;
	color: #ccc;
	padding: 0 12px 2px;
}

.index-wrapper {
	display: flex;
	justify-content: space-between;
	width: 1160px;
	height: 76px;
	margin-bottom: 40px;
}
.index-item {
	width: 260px;
	height: 76px;
}
.index-item-top {
	margin-bottom: 10px;
	height: 22px;
	line-height: 22px;
	display: flex;
	p {
		font-size: 20px;
	}
}
.index-item-top a {
	margin-left: 8px;
	font-size: 12px;
}
.index-item-bottom {
	white-space: normal;
	word-break: break-all;
	word-wrap: break-word;
	width: 265px;
	height: 50px;
	overflow: hidden;
}
.index-item-bottom a {
	display: inline-block;
	vertical-align: top;
	height: 19px;
	line-height: 19px;
	font-size: 14px;
	color: #6c7579;
	margin-right: 20px;
	margin-bottom: 6px;
	&:hover {
		color: #00a1d6;
	}
}

.select {
	width: 1160px;
	height: 192px;
	margin-bottom: 40px;
}
.select-left {
	width: 900px;
	height: 192px;
	float: left;
	overflow: hidden;
}
.select-left-title {
	height: 24px;
	margin-bottom: 20px;
	padding-right: 20px;
}
.select-left-title p {
	float: left;
	font-size: 24px;
	font-weight: 400;
	line-height: 24px;
	margin-right: 30px;
	color: #222;
	cursor: auto;
}
.select-left-title div {
	float: right;
	cursor: pointer;
	background-color: #fff;
	border: 1px solid #ccd0d7;
	border-radius: 4px;
	height: 22px;
	padding: 0 10px;
	transition: all 0.2s;
	font-size: 12px;
	&:hover {
		background-color: #ccd0d7;
	}
}
.select-left-title div i {
	display: inline-block;
	width: 12px;
	height: 13px;
	vertical-align: top;
	-webkit-transition: all 0.5s;
	-o-transition: all 0.5s;
	transition: all 0.5s;
	margin-top: 5px;
	background-position: -475px -89px;
	background-image: url(./static/images/icons.png);
	&:hover {
		transform: rotate(1turn);
	}
}
.select-left-title div span {
	display: inline-block;
	vertical-align: top;
	line-height: 22px;
	margin-left: 5px;
}
.select-left-content {
	height: 148px;
}
.select-left-content li {
	width: 160px;
	margin: 0 20px 20px 0;
	height: 150px;
	float: left;
	overflow: hidden;
	cursor: pointer;
	&:hover p {
		color: #00a1d6;
	}
}
.select-left-content div {
	width: 100%;
	height: 100px;
	border-radius: 4px;
	overflow: hidden;
	position: relative;
}
.select-left-content div img {
	width: 100%;
	height: 100%;
}
.select-left-content div i {
	position: absolute;
	width: 38px;
	height: 33px;
	background: url(./static/images/jingxuan-tag.png) no-repeat;
	top: 0;
	right: 6px;
	z-index: 10;
}
.select-left-content p {
	height: 44px;
	overflow: hidden;
	margin-top: 5px;
	font-size: 12px;
	white-space: normal;
	line-height: 22px;
}
.select-right {
	float: right;
	width: 260px;
}
.select-right-title {
	height: 24px;
	margin-bottom: 20px;
}
.select-right-title p {
	float: left;
	font-size: 24px;
	font-weight: 400;
	line-height: 24px;
	margin-right: 30px;
	color: #222;
	cursor: auto;
}
.select-right-content {
	width: 100%;
	height: 148px;
	position: relative;
	overflow: hidden;
}
.select-right-content ul {
	height: 100%;
	white-space: nowrap;
	transform: translateX(-100%);
	transition-duration: 0.3s;
	transition: transform 0.3s ease, -webkit-transform 0.3s ease;
}
.select-right-content li {
	display: inline-block;
	vertical-align: top;
	position: relative;
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	overflow: hidden;
}
.select-right-content img {
	display: block;
	width: 100%;
	height: 100%;
	line-height: 44px;
	font-size: 12px;
	text-align: center;
	border-radius: 5px;
}

.finish {
	display: flex;
	.finish-right {
		display: flex;
		flex-direction: column;
	}
}

.back-to-top {
	cursor: pointer;
	width: 50px;
	height: 50px;
	background-color: #f7f9fa;
	border-radius: 3px;
	position: fixed;
	bottom: 50px;
	left: 50%;
	margin-left: 590px;
	&:hover {
		background-color: #00a1d6;
	}
	&:hover span {
		color: white;
	}
	span {
		font-size: 24px;
		position: absolute;
		top: 14px;
		left: 16px;
		color: grey;
	}
}
.noshow {
	display: none;
}
.play {
	overflow: hidden;
}
</style>
